import api from "./helper";
const { _get, _post, _delete, _put } = api;
const TRADITION_MODEL = 2;
const BATCH = 3;
// base
const base = {
  changePassword: _get("/user/changePassword"),
  login: _post("account/api/login", TRADITION_MODEL),
  register: _post("account/api/regist"),
  upload: _post("/util/newUploadFile"),
};
// user
const user = {
  getUser: _get("user/list"),
  getUserList: _get("user/pageUser"),
  addUser: _post("user/insert"),
  getOrderByUser: _get("/user/pageUserOrder"),
  editUser: _put("user/updateIgnoreNull"),
  deleteUser: _delete("user/delete"),
};
// file
const file = {
  getFile: _get("/list/list"),
  // done id 无法修改
  getFileById: _get("util/getFilesByUserId"),
  addFile: _post("/list/insert"),
  editFile: _put("/list/updateIgnoreNull"),
};
// category
const category = {
  getCategory: _get("lable/list"),
  getCategoryList: _get("lable/pageLable"),
  addCategory: _post("lable/insert"),
  editCategory: _put("lable/updateIgnoreNull"),
  deleteCategory: _delete("lable/delete"),
};
// book
const book = {
  getBook: _get("/book/list"),
  getBookList: _get("book/pageBook"),
  addBook: _post("book/insert"),
  editBook: _put("book/updateIgnoreNull"),
  deleteBook: _delete("book/delete"),
};
// correction
// tag advice api ? use
// const correction = {
//     getCorrectionList: _get('addvice/pageAddvice'),
//     addCorrection: _post('addvice/insert'),
//     editCorrection: _put('addvice/updateIgnoreNull'),
//     deleteCorrection: _delete('addvice/delete')
// }
// borrow
const borrow = {
  getBorrowList: _get("borrow/pageBorrow"),
  addBorrow: _post("borrow/insert"),
  editBorrow: _put("borrow/updateIgnoreNull"),
  deleteBorrow: _delete("borrow/delete"),
};
// log
const log = {
  getLogList: _get("logs/page"),
  deleteLog: _delete("logs/delete"),
};
// errata
const errata = {
  getErrataList: _get("repair/pageRepair"),
  addErrata: _post("repair/insert"),
  editErrata: _put("repair/updateIgnoreNull"),
  deleteErrata: _delete("repair/delete"),
};
// pizhu
const pizhu = {
  getPizhu: _put("comment/getComment"),
  addPizhu: _post("comment/insert"),
  editPizhu: _put("comment/update"),
  deletePizhu: _delete("comment/delete"),
};
// chapter
const chapter = {
  getChapterById: _get("chapter/getByBookId"),
  addChapter: _post("chapter/insert"),
  editChapter: _put("chapter/update"),
  deleteChapter: _delete("chapter/delete"),
};

// post
const post = {
  getPostById: _get("post/getByBookId"),
  addPost: _post("post/addpost"),
  editPost: _put("post/update"),
  deletePost: _delete("post/deletepost"),
  getPostList: _get("post/getposts"),
  getMyPost: _get("post/getMyPost"),
};

// comment
const comment = {
  getCommentByPostId: _get("post/getcomment"),
  deleteComment: _delete("post/deletepost"),
  getCommentList: _get("/post/getposts"),
  // getPostById: _get('post/getByBookId'),
  addComment: _post("post/addcomment"),
  // editPost: _put('post/update'),
  // deletePost: _delete('post/delete')
};

const notice = {
  // getNotices: _get('/apiNotice/list'),
  getNoticeList: _get("/apiNotice/page"),
  addNotice: _post("/apiNotice/insert"),
  editNotice: _put("/apiNotice/update"),
  deleteNotice: _delete("/apiNotice/delete", TRADITION_MODEL),
};

const shoppingCar = {
  getShoppingCar: _get("/apiShoppingCar/list"),
  getShoppingCarList: _get("/apiShoppingCar/pageList"),
  getShoppingCarById: _get("/apiShoppingCar/getById"),
  addShoppingCar: _post("/apiShoppingCar/insert"),
  editShoppingCar: _put("/apiShoppingCar/update"),
  deleteShoppingCarList: _delete("/apiShoppingCar/batchDelete", BATCH),
  deleteShoppingCar: _delete("/apiShoppingCar/delete", TRADITION_MODEL),
};

const goodsOrder = {
  getGoodsOrder: _get("/apiGoodsOrder/list"),
  getGoodsOrderList: _get("/apiGoodsOrder/pageList"),
  addGoodsOrderList: _post("/apiGoodsOrder/batchInsert"),
  addGoodsOrder: _post("/apiGoodsOrder/insert"),
  editGoodsOrder: _put("/apiGoodsOrder/update"),
  deleteGoodsOrder: _delete("/apiGoodsOrder/delete", TRADITION_MODEL),
};
const point = {
  getPointPage: _get("/apiUserPoints/pageList"),
  deletePoint: _delete("/apiUserPoints/delete", TRADITION_MODEL),
  addPoint: _post("/apiUserPoints/insert"),
  editPoint: _put("/apiUserPoints/update"),
  searchPoint: _get("/apiUserPoints/getById"),
  getPointByUserId: _get("/apiUserPoints/selectByUserId"),
  getOrderByPoints: _get("/apiUserPoints/orderByPoints"),
};
const publicComment = {
  getPublicPage: _get("/apiNotice/pageList"),
  deletePublic: _delete("/apiNotice/delete", TRADITION_MODEL),
  addPublic: _post("/apiNotice/insert"),
  editPublic: _put("/apiNotice/update"),
  searchPublic: _get("/apiNotice/getById"),
  getAllPubilc: _get("/apiNotice/list")
};

const count = {
  getStatisticData: _get("/apiUserPoints/tongji"),
}
export default {
  ...base,
  ...category,
  ...user,
  ...file,
  ...book,
  ...post,
  ...comment,
  // ...correction,
  ...borrow,
  ...log,
  ...errata,
  ...pizhu,
  ...chapter,
  ...shoppingCar,
  ...notice,
  ...goodsOrder,
  ...point,
  ...publicComment,
  ...count
};
